package com.example.logprocess.repository.convert;

import cn.hutool.core.date.DateUtil;
import com.example.logprocess.model.LogItem;
import com.example.logprocess.repository.entity.LogEntity;
import org.mapstruct.Mapper;
import org.mapstruct.MappingConstants;

@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
public interface LogConvert {

    LogEntity toLogEntity(LogItem logItem);

    default Long map(String date) {
        if (date == null) return null;
        return DateUtil.parse(date, "yyyy-MM-dd HH:mm:ss.SSS").getTime();
    }
}
